#include <stdio.h>

int main()
{
    FILE *fp1, *fp2;
    char ch;
    fp1 = fopen("test1.txt", "r");//以读方式打开test1.txt
    fp2 = fopen("test2.txt", "w");//以写方式打开test2.txt
    while (feof(fp1)== 0) //fp1没有结束时候
    {
        ch = fgetc(fp1);//从fp1中读取一个字符
        //如果到达文件结尾，结束循环
        if (feof(fp1) != 0)
            break;
        fputc(ch, fp2);//把ch写入fp2
    }
   
    fclose(fp1);
    fclose(fp2);
    return 0;
}


